def pop(firstlist,secondlist):
    result=[]
    while firstlist and secondlist:
        if firstlist[0][0]>secondlist[0][1]:
            secondlist.pop(0)
        elif firstlist[0][1]<secondlist[0][0]:
            firstlist.pop(0)
        else:
            if firstlist[0][0]>secondlist[0][0]:
                a= firstlist[0][0]
            else :
                a=secondlist[0][0]
            if firstlist[0][1]>secondlist[0][1]:
                b=secondlist[0][1]
            else :
                b=firstlist[0][1]
            result.append([a,b])
            if firstlist[0][1]<secondlist[0][1]:
                firstlist.pop(0)
            else:
                secondlist.pop(0)
    return result

list1=[[0,2],[5,10],[13,23],[24,25]]
list2=[[1,5],[8,12],[15,24],[25,26]]
print(pop(list1,list2))